package ui;

/*读者功能选择*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class ReaderOp extends JFrame implements ActionListener  {
	private JButton selectbookButton;
	private JButton BorrowSystemButton;
	private JButton returnbutton;
	public ReaderOp() {
		JFrame jFrame = new JFrame("读者功能选择");
		//JPanel jpc = new JPanel();// 默认流式布局
		jFrame.setLayout(new BorderLayout());
		//jFrame.setSize(300, 200);
		JPanel jp1 = new JPanel(new GridLayout(1, 2, 10, 10));//设置新面板
		// 网格布局GridLayout(int rows, int columns, int hgap, int vgap)行数，列数，组件水平间距，垂直间距
		jp1.setBorder(BorderFactory.createTitledBorder("读者功能选择"));
		//this.setLayout(new FlowLayout());
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

		setTitle("读者功能选择界面");
		setSize(300, 150);
		setLocationRelativeTo(null);
		

		// 监听右上角的退出按钮
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent windowEvent) {
				System.exit(0);
			}
		});
		selectbookButton = new JButton("书籍查询系统");
		BorrowSystemButton = new JButton("借阅管理系统");
		
		jp1.add(selectbookButton);
		jp1.add(BorrowSystemButton);JPanel jp2 = new JPanel();
		returnbutton = new JButton("退出登录");
		returnbutton.addActionListener(this);
		returnbutton.setActionCommand("no");
		jp2.add(returnbutton);
		add(jp2, BorderLayout.SOUTH);// 把按钮放到窗口最下方
		getContentPane().add(jp1,BorderLayout.CENTER);

		selectbookButton.addActionListener(this);
		BorrowSystemButton.addActionListener(this);

		this.setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == selectbookButton) {
			this.dispose();
			new BookSearchButtons();
		} else if (e.getSource() == BorrowSystemButton) {
			this.dispose();
			new BorrowSystemOp();
		} else if (e.getSource() == returnbutton) {
			this.dispose();
			new Bind();
		} 
	}
}
